#ifndef __03_HEADER__
#define __03_HEADER__
//第三期项目的头文件
#include "my_header.h"
typedef enum command_s{
    CD = 1,
    LS,
    PUTS,
    GETS,
    REMOVE,
    PWD,
    MKDIR,
    RMDIR,
    AUTH = 100,
    SIGN_IN = 101,
    DEL = 102
}command_t;

typedef struct train_s{
    int type;//代表本次传输的命令的种类，长度4B
    int lenth;//代表小火车正文的长度，长度4B
    char value[1024];//代表要传输的命令正文
}train_t;

//传输文件专用TLV
typedef struct{
    int length;
    command_t tag;
    char data[256];
}TLV;
//注册登录验证功能
//int signInAndAuthPasswd(int netfd, char* basePath, int size);
//void show_dir(int netfd,char* cur_dir,int len);//pwd用
int signInAndAuthPasswd(int netfd, char* basePath, int size, char *pUsername, MYSQL *connect);

//接收命令
int recvRequest(int netfd, train_t *train);
int sendRequest(int netfd, const char *request, int type);

//处理命令
//void show_dir(int netfd, char* cur_dir, int len);
int jump_to_dir(char* cur_dir, MYSQL* db);
int add_dir(char* cur_dir, char* username, char* dirname, int pwd, MYSQL* db);
int remove_dir(char* cur_dir, char* dirname, int *pwd, MYSQL* db);
void list_dir(int pwd, char *nameList, MYSQL* db);
void change_dir(char* cur_dir, char* command, char *username, int *pwd, MYSQL *db);

//传输文件功能
void gets_file(MYSQL *db,int netfd,char *Data,char *realPath);
//void puts_file(int netfd, MYSQL *db, char *Data, char *realPath, char *cur_user_pwd, int cur_dirid, int user_id);
void puts_file(int netfd, MYSQL *db,char *Data, char *realPath, char *cur_user_pwd,int cur_dirid, char *username);
//puts_file(int netfd, MYSQL *connect,char *filename, char *basePath, char *tmpPath,int parent_id, char *username)
int recvfile(int sockfd, char* pathname);
int transfile(int sockfd, char * pathname);

//加密哈希值功能
void hash_compute(char *sha1str,char *pathname);

//删除文件表项功能
int is_exist_data(MYSQL *db, char *filename, char *cur_user_pwd, char *username);
void remove_dir_or_file(MYSQL *db, char *filename, char *cur_user_pwd, int cur_dirid, char *username);
#endif
